function formatNum(num) {
    let str = String(num);
    return str.length === 1 ? '0' + str : str;
}
export default {
 
    // 返回当前版本号，注意 此方法为异步方法
    appInterfaceVersion() {
        return new Promise((resolve, reject) => {
            window.bridge.callHandler('appInterfaceVersion', {}, function (response) {
                if (typeof response == 'string') {
                    response = JSON.parse(response)
                }
                console.log("获取版本号信息...");
                console.log(response);
                console.log(response.app_version);
                resolve(response.app_version);
            })
        })
    },
    // ver1为当前版本号 ver2为最低兼容版本
    compareAppVersion(ver1, ver2) {
        let version1 = ver1; //当前手机app的版本号
        let version2 = ver2;        //被比较的app版本号
        let v_1 = version1.split('.');
        let v_2 = version2.split('.');
        let minL = Math.min(v_1.length, v_2.length);
        for (let i = 0; i < minL; ++i) {
            console.log(i);
            console.log(v_1[i], v_2[i]);
            if (parseInt(v_1[i], 10) < parseInt(v_2[i], 10)) {    //当前手机app版本号较低
                return false;
            } else if (parseInt(v_1[i], 10) > parseInt(v_2[i], 10)) {
                return true;             //当前app版本号较高
            } else if (i == minL - 1 && parseInt(v_1[i], 10) == parseInt(v_2[i], 10)) {
                return true;             //当前版本号与被比较的版本号一样
            }
        }
    },


    //银行卡
    getCard(str) {
        return str.replace(/^(\d{4})\d+(\d{4})$/, '$1 **** $2')
    },
    //
    toThousands(num) {
        return (num || 0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
    },
    //过滤数字
    getNumber(num) {
        console.log("num1+++", num)
        num = parseFloat(num)
        console.log("num2+++", num)
        num = num.toFixed(2)
        console.log("num3+++", num)
        num = parseFloat(num)
        console.log("num4+++", num)
        //  num = num.toLocaleString()
        // num = num + '.00';
        if (Math.round(num) === num) {
            num = num + '.00'
            console.log("num5+++", num)
            return num
        } else {
            console.log("num6+++", num)
            return num
        }
    },
    //电话号码
    getPhone(str) {
        return str ? str.replace(/^(\d{3})\d+(\d{4})$/, '$1****$2') : ''
    },
    // 钱数格式化
    moneyNumFormat(num) {
        if (isNaN(Number(num))) {
            return num
        } else {
            let numStr = String(num)
            let _int = numStr.split('.')[0]
            let _flo = numStr.split('.')[1]
            _int = _int.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
            if (_flo) {
                if (_flo.length >= 2) {
                    _flo = _flo.substr(0, 2)
                } else if (_flo.length === 1) {
                    _flo += '0'
                }
            } else {
                _flo = '00'
            }
            return `${_int}.${_flo}`
        }
    },
    //
    strToDateSlash(dateStr) {
        const RE_DATE = /(\d{4})(\d{2})(\d{2})/
        const matchObj = RE_DATE.exec(dateStr)
        return matchObj[1] + '/' + matchObj[2] + '/' + matchObj[3]
    },
    //输入框只允许输入小数点后2位
    pushNumber(num) {
        return num.match(/^\d*(\.?\d{0,1})/g)[0]
    },
    //根据最小月和最大月得到月份数组
    getMonthList(min, max) {
        let arr = []
        for (let i = min; i <= max; i++) {
            arr.push(`${i}个月`)
        }
        return arr
    },
    clearNoNum(e) {
        e.target.value = e.target.value.replace(/[^\d.]/g, '')
        e.target.value = e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]
    },
    // 贷款用途
    getLoanUseName(key) {
        let map = new Map()
        map.set('01', '个人消费')
        map.set('02', '公共租赁房建设')
        map.set('03', '经济适用房建设')
        map.set('04', '棚改安置用房建设')
        map.set('05', '其他')
        map.set('06', '其他与住房无关项目')
        map.set('07', '其他住房建设')
        map.set('08', '生产经营')
        map.set('09', '限价商品房建设')
        map.set('10', '支持个人购买住房')
        map.set('11', '项目建设')
        map.set('12', '项目运营')
        map.set('13', '固定资产投资与购置')
        map.set('14', '债务置换')
        map.set('15', '混合用途')
        map.set('16', '经营周转')
        map.set('17', '项目前期')
        map.set('18', '后续运营维护')
        return map.get(key)
    },
    // 解析url
    parsUrl(urlStr) {
        let decStr = decodeURI(urlStr)
        let arr = decStr.split('&')
        let obj = {}
        for (let i = 0; i < arr.length; i++) {
            let inArr = arr[i].split('=')
            obj[inArr[0]] = inArr[1]
        }
        obj.result = JSON.parse(obj.result)
        return obj
    },
    //获取url信息对象
    getUrlResObj(str) {
        try {
            if (!str || str === '') {
                str = window.location.search.substr(1)
            }
            if (str.length === 0) {
                return {
                    code: 1,
                    data: null,
                    msg: '未获取到数据'
                }
            } else {
                return {
                    code: 0,
                    data: this.parsUrl(str),
                    msg: 'success'
                }
            }
        } catch (err) {
            return {
                code: 1,
                data: null,
                msg: err
            }
        }
    },
    JSONParse(json) {
        if (typeof json === 'string') {
            json = JSON.parse(json)
        }
        return json
    },
    // 还款方式中文
    getRepMedText(key) {
        let map = new Map()
        map.set('311', '等额本息')
        map.set('100', '一次性还本付息')
        map.set('200', '期初付息，到期还本')
        map.set('300', '分期还款')
        map.set('310', '等额还款')
        map.set('312', '等本等息')
        map.set('320', '等额本金')
        map.set('330', '按固定周期付息，到期还本')
        map.set('340', '随时还本，按月还息')
        map.set('350', '按固定周期付息，按计划还本')
        map.set('360', '等额累进法')
        map.set('370', '等比累进法')
        map.set('400', '利随本清还款法')
        map.set('500', '只还息')
        map.set('510', '住储等额还款法')
        map.set('520', '预先还款法')
        map.set('999', '其他方式')
        return map.get(key)
    },
    // 解决created两次问题
    doOnce(name, fn) {
        if (!window.sessionStorage.getItem(name) ||
            window.sessionStorage.getItem(name) === '2'
        ) {
            window.sessionStorage.setItem(name, '1')
        } else {
            window.sessionStorage.setItem(name, '2')
            fn()
        }
    },
    removeDoOnce(name) {
        window.sessionStorage.removeItem(name)
    },
    numToTxt(num) {
        return String(num).length === 1 ? '0' + num : '' + num
    },
    // 数字转中文钱数
    toChineseMoney(n) {
        if (n == 0 || n == '' || n == undefined) {
            return '零元整'
        }
        if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(n)) return '数据非法'
        let unit = '京亿万仟佰拾兆万仟佰拾亿仟佰拾万仟佰拾元角分',
            str = ''
        n += '00'
        let p = n.indexOf('.')
        if (p >= 0) n = n.substring(0, p) + n.substr(p + 1, 2)
        unit = unit.substr(unit.length - n.length)
        for (let i = 0; i < n.length; i++)
            str += '零壹贰叁肆伍陆柒捌玖'.charAt(n.charAt(i)) + unit.charAt(i)
        return str
            .replace(/零(仟|佰|拾|角)/g, '零')
            .replace(/(零)+/g, '零')
            .replace(/零(兆|万|亿|元)/g, '$1')
            .replace(/(兆|亿)万/g, '$1')
            .replace(/(京|兆)亿/g, '$1')
            .replace(/(京)兆/g, '$1')
            .replace(/(京|兆|亿|仟|佰|拾)(万?)(.)仟/g, '$1$2零$3仟')
            .replace(/^元零?|零分/g, '')
            .replace(/(元|角)$/g, '$1整')
    },
    monthToNumStr(mon) {
        let str = mon.replace(/个月/, '')
        if (str.length === 1) {
            str = '0' + str
        }
        return str
    },
    strToDateChinese(dateStr) {
        const RE_DATE = /(\d{4})(\d{2})(\d{2})/
        const matchObj = RE_DATE.exec(dateStr)
        return matchObj[1] + '年' + matchObj[2] + '月' + matchObj[3] + '日'
    },
    //汉字的数字
    convertCurrency(money) {
        //汉字的数字
        let cnNums = new Array(
            '零',
            '一',
            '二',
            '三',
            '四',
            '五',
            '六',
            '七',
            '八',
            '九'
        ) //基本单位
        let cnIntRadice = new Array('', '十', '百', '千') //对应整数部分扩展单位
        let cnIntUnits = new Array('', '万', '亿', '兆') //对应小数部分单位
        let cnDecUnits = new Array('角', '分', '毫', '厘') //整数金额时后面跟的字符
        let cnInteger = '整' //整型完以后的单位
        let cnIntLast = '元' //最大处理的数字
        let maxNum = 999999999999999.9999 //金额整数部分
        let integerNum //金额小数部分
        let decimalNum //输出的中文金额字符串
        let chineseStr = '' //分离金额后用的数组，预定义
        let parts
        if (money == '') {
            return ''
        }
        money = parseFloat(money)
        if (money >= maxNum) {
            //超出最大处理数字
            return ''
        }
        if (money == 0) {
            chineseStr = cnNums[0] + cnIntLast + cnInteger
            return chineseStr
        } //转换为字符串
        money = money.toString()
        if (money.indexOf('.') == -1) {
            integerNum = money
            decimalNum = ''
        } else {
            parts = money.split('.')
            integerNum = parts[0]
            decimalNum = parts[1].substr(0, 4)
        } //获取整型部分转换
        if (parseInt(integerNum, 10) > 0) {
            let zeroCount = 0
            let IntLen = integerNum.length
            for (let i = 0; i < IntLen; i++) {
                let n = integerNum.substr(i, 1)
                let p = IntLen - i - 1
                let q = p / 4
                let m = p % 4
                if (n == '0') {
                    zeroCount++
                } else {
                    if (zeroCount > 0) {
                        chineseStr += cnNums[0]
                    } //归零
                    zeroCount = 0
                    chineseStr += cnNums[parseInt(n)] + cnIntRadice[m]
                }
                if (m == 0 && zeroCount < 4) {
                    chineseStr += cnIntUnits[q]
                }
            }
            chineseStr += cnIntLast
        } //小数部分
        if (decimalNum != '') {
            let decLen = decimalNum.length
            for (let i = 0; i < decLen; i++) {
                let n = decimalNum.substr(i, 1)
                if (n != '0') {
                    chineseStr += cnNums[Number(n)] + cnDecUnits[i]
                }
            }
        }
        if (chineseStr == '') {
            chineseStr += cnNums[0] + cnIntLast + cnInteger
        } else if (decimalNum == '') {
            chineseStr += cnInteger
        }
        return chineseStr
    },
    getIntRtClcnSymbStr(cd) {
        if (cd === '1') {
            return '加'
        } else if (cd === '2') {
            return '减'
        } else if (cd === '3') {
            return '乘'
        } else if (cd === '4') {
            return '除'
        }
    },
    getSystemDateChinese(boolean) {
        let d = new Date()
        if (boolean) {
            return (
                ` <span class='underline'>${d.getFullYear()}</span> 年 <span class='underline'>${this.numToTxt(d.getMonth() + 1)}</span> 月 <span class='underline'>${this.numToTxt(d.getDate())}</span> 日`
            )
        }
        return (
            `${d.getFullYear()}年${d.getMonth() + 1}月${d.getDate()}日`
        )
    },
    getNowFormatDate() {
        var date = new Date();
        var seperator1 = "/";
        var year = date.getFullYear(); //年
        var month = date.getMonth() + 1; //月
        var strDate = date.getDate(); //日
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = year + seperator1 + month + seperator1 + strDate;
        return currentdate;
    },
    getpremooth() {
        let nowdays = new Date()
        let year = nowdays.getFullYear()
        let month = nowdays.getMonth()
        if (month == 0) {
            month = 12
            year = year - 1
        }
        if (month < 10) {
            month = '0' + month
        }

        let myDate = new Date(year, month, 0)
        let startDate = year + '-' + month //+'-01 00:00:00'; //上个月第一天
        let endDate = year + '-' + month + '-' + myDate.getDate() //+' 23:59:00';//上个月最后一天

        return endDate
    },
    getSystemDateTomorrow() {
        let d = new Date()
        let months = d.getMonth() + 1
        let dates = d.getDate() - 1
        if (months < 10) {
            months = '0' + months
        }
        if (dates < 10) {
            dates = '0' + dates
        }
        let tomorrow = d.getFullYear() + '-' + months + '-' + dates
        if (dates == '00') {
            tomorrow = this.getpremooth()
        }
        return tomorrow
    },

    androidInput() {
        // 处理安卓手机输入法遮挡输入框问题
        console.log('进入方法')
        if (/Android/gi.test(navigator.userAgent)) {
            console.log('是安卓')
            window.addEventListener('resize', function () {
                if (
                    document.activeElement.tagName == 'INPUT' ||
                    document.activeElement.tagName == 'TEXTAREA'
                ) {
                    console.log('处理安卓手机输入法遮挡输入框问题')
                    window.setTimeout(function () {
                        document.activeElement.scrollIntoViewIfNeeded()
                    }, 0)
                }
            })
        }
    },
    strToDateSlash(dateStr) {
        if (!dateStr) return
        const RE_DATE = /(\d{4})(\d{2})(\d{2})/
        const matchObj = RE_DATE.exec(dateStr)
        return matchObj[1] + '/' + matchObj[2] + '/' + matchObj[3]
    },
    dateJoiningTogethe(dateStr) {
        //时间格式20190509
        let today =
            new Date().getFullYear() +
            '' +
            (new Date().getMonth() + 1 >= 10 ?
                new Date().getMonth() + 1 :
                '0' + (new Date().getMonth() + 1)) +
            (new Date().getDate() > 9 ?
                new Date().getDate() :
                '0' + new Date().getDate())
        return today
    },
    specialCharacter(s) {
        let pattern = new RegExp(
            "[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？%]"
        )
        let rs = ''
        for (let i = 0; i < s.length; i++) {
            rs = rs + s.substr(i, 1).replace(pattern, '')
        }
        return rs
    },
    reponseTime(times) {
        // console.log(times)
        let years = times.substr(0, 4)
        let months = times.substr(4, 2)
        let days = times.substr(6, 2)
        return years + '-' + months + '-' + days
    },
    reponseTimes(val) {
        if (!val) return ""
        // console.log(val)
        let years = val.substr(0, 4)
        let months = val.substr(4, 2)
        let days = val.substr(6, 2)
        return `${years}年${months}月${days}日`
    },
    timestamp(val) {
        if (!val) {
            return "";
        }
        let date = new Date(Number(val));
        let Y = date.getFullYear() + "年";
        let M =
            (date.getMonth() + 1 < 10 ?
                "0" + (date.getMonth() + 1) :
                date.getMonth() + 1) + "月";
        let D = date.getDate();
        D = D < 10 ? "0" + D + "日" + " " : D + "日";
        let h = date.getHours();
        h = h < 10 ? "0" + h + ":" : h + ":";
        let m = date.getMinutes();
        m = m < 10 ? "0" + m : m;
        return Y + M + D + "  " + h + m;
    },
    testPasw(str) {
        return (!/\W/g.test(str) &&
            /[0-9]/g.test(str) &&
            /[a-z]/g.test(str) &&
            /[A-Z]/g.test(str) &&
            str.length >= 8 &&
            str.length <= 20
        )
    },
    functiontransdate(endTime) {
        //日期转时间戳
        let t = this.reponseTime(endTime)
        let T = new Date(t)
        let times = T.getTime()
        return times //Date.parse(date) / 1000
    },
    formatDate(date) {
        //日历控件选择时间转换yyyymmdd
        const y = date.getFullYear()
        let m = date.getMonth() + 1
        m = m < 10 ? '0' + m : m
        let d = date.getDate()
        d = d < 10 ? ('0' + d) : d
        return y + '-' + m + '-' + d
    },
    formatDateHour(date) {
        //日历控件选择时间转换yyyymmdd
        const y = date.getFullYear()
        let h = date.getHours()
        h = h < 10 ? '0' + h : h
        let m = date.getMinutes()
        m = m < 10 ? '0' + m : m
        let s = date.getSeconds()
        s = s < 10 ? ('0' + s) : s
        return h + ':' + m + ':' + s
    },
    formatDateMin(date) {
        //日历控件选择时间转换yyyymmddhhss
        const y = date.getFullYear()
        let m = date.getMonth() + 1
        m = m < 10 ? '0' + m : m
        let d = date.getDate()
        d = d < 10 ? ('0' + d) : d
        let h = date.getHours()
        h = h < 10 ? ('0' + h) : h
        let s = date.getMinutes()
        s = s < 10 ? ('0' + s) : s
        return y + ' ' + m + ' ' + d + ' ' + h + ' ' + s
    },
    formatTime(val) {
        if (!val) {
            return "";
        }
        let date = new Date(Number(val));
        var Y = date.getFullYear() + "年";
        var M =
            (date.getMonth() + 1 < 10 ?
                "0" + (date.getMonth() + 1) :
                date.getMonth() + 1) + "月";
        var D = date.getDate();
        D = D < 10 ? "0" + D + "日" + " " : D + "日";
        var h = date.getHours();
        h = h < 10 ? "0" + h + ":" : h + ":";
        var m = date.getMinutes();
        m = m < 10 ? "0" + m : m;
        return Y + M + D + "" + h + m;
    },
    toString(val) {
        return val == null ?
            '' :
            Array.isArray(val) || (this.isPlainObject(val) && val.toString === _toString) ?
                JSON.stringify(val, null, 2) :
                String(val)
    },

    formatCity(str) {
        let area = {}
        let index11 = 0
        let index1 = str.indexOf("省")
        if (index1 == -1) {
            index11 = str.indexOf("自治区")
            if (index11 != -1) {
                area.Province = str.substring(0, index11 + 3)
            } else {
                area.Province = str.substring(0, 0)
            }
        } else {
            area.Province = str.substring(0, index1 + 1)
        }

        let index2 = str.indexOf("市")
        if (index11 == -1) {
            area.City = str.substring(index11 + 1, index2 + 1)
        } else {
            if (index11 == 0) {
                area.City = str.substring(index1 + 1, index2 + 1)
            } else {
                area.City = str.substring(index11 + 3, index2 + 1)
            }
        }

        let index3 = str.lastIndexOf("区")
        if (index3 == -1) {
            index3 = str.indexOf("县")
            area.Country = str.substring(index2 + 1, index3 + 1)
        } else {
            area.Country = str.substring(index2 + 1, index3 + 1)
        }
        return area;

    },
    checkCity(data, selectCity) {
        let selectCityCode
        for (let i in data) {
            for (let k in data[i]) {
                if (data[i][k] === selectCity) {
                    selectCityCode = k
                }
            }
        }
        return selectCityCode
    },
    descFormatSpace(str) {
        if (!str) return
        return str.replace(/<\/?.+?\/?>|\s+/g, "")
        // return str.replace(/<\/{0,}[a-z](.+?)>/gi," ")
        // return str.replace(/\^p/g,'')
    },
    descFormat(str) {
        if (!str) return
        return str.replace(/<\/?.+?\/?>/g, "")
    },
    moinsZero(str) {
        if (!str) return
        return str < 10 ? "0" + str : str
    },
    getQueryString(name) {
        let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        if (window.location.hash.indexOf("?") < 0) return null;
        let r = window.location.hash.split("?")[1].match(reg);
        if (r != null) return decodeURIComponent(r[2]);
        return null;
    },
    GetRequest() {
        var url = location.search
        var theRequest = new Object()
        if (url.indexOf('?') != -1) {
            var strs = url.substr(1)
            strs = strs.split('&')
            for (var i = 0; i < strs.length; i++) {
                let objname = decodeURIComponent(strs[i].split('=')[0])
                let objvalue = decodeURIComponent(strs[i].split('=')[1])
                theRequest[objname] = unescape(objvalue)
            }
        }
        return theRequest
    },
    foreachData(billData) {
        let billDataInfo = {}
        for (let i = 0, len = billData.length; i < len; i++) {
            billDataInfo[billData[i].itemname] =
                billData[i].itemvalue;
        }
        return billDataInfo
    },
    timeHd(value, flag) {
        if (!value) return "";
        let time
        switch (flag) {
            case 'year':
                time = value.substr(0, 4)
                break;
            case 'mouth':
                time = value.substr(4, 2)
                break;
            default:
                time = value.substr(6, 2)
                break;
        }
        return time
    },
    formatMoney(m) {
        if (!m) return "";
        if (/(^[1-9]\d*$)/.test(m / 10000)) {
            return m / 10000 + "万元";
        } else {
            return (m + "").replace(/\d{1,3}(?=(\d{3})+$)/g, "$&,") + "元";
        }
    },
    formatDateNow() {
        let date = new Date();//实例一个时间对象；
        let year = date.getFullYear() + "";//获取系统的年；
        let month = formatNum((date.getMonth() + 1));//获取系统月份，由于月份是从0开始计算，所以要加1
        let day = formatNum(date.getDate());//获取系统日
        let hour = formatNum(date.getHours());//获取系统时间
        let minute = formatNum(date.getMinutes()); //分
        let second = formatNum(date.getSeconds());//秒
        console.log("year+month+day+hour+minute+second", year + month + day + hour + minute + second)
        return (year + month + day + hour + minute + second)
    },
    wakeBaidu(lng, lat, eaddr) {
        // var geolocation = new BMap.Geolocation();
        // geolocation.getCurrentPosition(function (result) {
        // if (this.getStatus() == BMAP_STATUS_SUCCESS) {
        /*  var latCurrent = result.point.lat; //获取到的纬度
         var lngCurrent = result.point.lng; //获取到的经度 */
        var latCurrent = lat; //获取到的纬度
        var lngCurrent = lng; //获取到的经度
        var urlObject = {
            lat: lat,
            lng: lng,
            city: eaddr,
        }
        if (latCurrent && lngCurrent) {
            var scheme = '';

            // urlObject 是我这边地址栏查询参数对象
            //   var queryStr = '?origin=name:我的位置|latlng:' + latCurrent + ',' + lngCurrent + '&destination=' + urlObject.lat + ',' + urlObject.lng + '&region=' + urlObject.city + '&coord_type=bd09ll&mode=driving';
            var queryStr = '?origin=name:我的位置|latlng:' + latCurrent + ',' + lngCurrent + '&destination=' + urlObject.lat + ',' + urlObject.lng + '&region=' + urlObject.eaddr + '&coord_type=bd09ll&mode=driving';
            console.log("queryStr+++", queryStr)
            const u = navigator.userAgent;
            const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
            if (isiOS) {
                // ios 端
                scheme = 'baidumap://map/direction' + queryStr;
            } else {
                // android 端
                scheme = 'bdapp://map/direction' + queryStr;
            }

            // 主要实现代码
            window.location.href = scheme;

            var startTime = Date.now();
            var count = 0;
            var endTime = 0;

            var t = setInterval(function () {
                count += 1;
                endTime = Date.now() - startTime;
                if (endTime > 800) {
                    clearInterval(t);
                }
                if (count < 30) return;
                if (!(document.hidden || document.webkitHidden)) {
                    // window.location.href = 'http://api.map.baidu.com/direction' + queryStr + '&output=html';
                    Vue.$toast({
                        message: "请您先下载百度地图",
                        position: "middle",
                        duration: 1500
                    });
                }
            }, 20);

            window.onblur = function () {
                clearInterval(t);
            };
        } else {
            Vue.$toast({
                message: "获取不到定位，请检查手机定位设置",
                position: "middle",
                duration: 1500
            });
        }
        // }
        // });
    },
    wakeGaode(lng, lat, eaddr) {
        // var geolocation = new BMap.Geolocation();
        // geolocation.getCurrentPosition(function (result) {
        // if (this.getStatus() == BMAP_STATUS_SUCCESS) {
        /*  var latCurrent = result.point.lat; //获取到的纬度
         var lngCurrent = result.point.lng; //获取到的经度 */
        var latCurrent = lat; //获取到的纬度
        var lngCurrent = lng; //获取到的经度
        if (latCurrent && lngCurrent) {
            // urlObject 是我这边地址栏查询参数对象
            //   var queryStr = '?origin=name:我的位置|latlng:' + latCurrent + ',' + lngCurrent + '&destination=' + urlObject.lat + ',' + urlObject.lng + '&region=' + urlObject.city + '&coord_type=bd09ll&mode=driving';
            // var queryStr = '?origin=name:我的位置|latlng:' + latCurrent + ',' + lngCurrent + '&destination=' + urlObject.lat + ',' + urlObject.lng + '&region=' + urlObject.city + '&coord_type=bd09ll&mode=driving';
            const u = navigator.userAgent;
            const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
            // 苹果和安卓头部不一样
            let proto = isiOS ? 'iosamap://path' : 'amapuri://route/plan';
            // const scheme = proto + "?t= 0&slat=" + curLat + "&slon=" + curLng + "&sname=" + currAddr + "&dlat=" + elat + "&dlon=" + elng + "&dname=" + eaddr + "&src=xxx";
            const scheme = proto + "?t= 0&dlat=" + lat + "&dlon=" + lng + "&dname=" + eaddr + "&src=xxx";
            console.log("queryStr+++", scheme)
            // 主要实现代码
            // window.location.href = scheme;

            var startTime = Date.now();
            var count = 0;
            var endTime = 0;

            var t = setInterval(function () {
                count += 1;
                endTime = Date.now() - startTime;
                if (endTime > 800) {
                    clearInterval(t);
                }
                if (count < 30) return;
                if (!(document.hidden || document.webkitHidden)) {
                    Vue.$toast({
                        message: "请您先下载高德地图",
                        position: "middle",
                        duration: 1500
                    });
                }
            }, 20);

            window.onblur = function () {
                clearInterval(t);
            };
        } else {
            Vue.$toast({
                message: "获取不到定位，请检查手机定位设置",
                position: "middle",
                duration: 1500
            });
        }
        // }
        // });
    },
    wakeTengx(lng, lat, eaddr) {
        // var geolocation = new BMap.Geolocation();
        // geolocation.getCurrentPosition(function (result) {
        // if (this.getStatus() == BMAP_STATUS_SUCCESS) {
        /*  var latCurrent = result.point.lat; //获取到的纬度
         var lngCurrent = result.point.lng; //获取到的经度 */
        var latCurrent = lat; //获取到的纬度
        var lngCurrent = lng; //获取到的经度
        if (latCurrent && lngCurrent) {
            // urlObject 是我这边地址栏查询参数对象
            //   var queryStr = '?origin=name:我的位置|latlng:' + latCurrent + ',' + lngCurrent + '&destination=' + urlObject.lat + ',' + urlObject.lng + '&region=' + urlObject.city + '&coord_type=bd09ll&mode=driving';
            // var queryStr = '?origin=name:我的位置|latlng:' + latCurrent + ',' + lngCurrent + '&destination=' + urlObject.lat + ',' + urlObject.lng + '&region=' + urlObject.city + '&coord_type=bd09ll&mode=driving';
            // const u = navigator.userAgent;
            // const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
            const scheme = `qqmap://map/search?keyword=${eaddr}`
            console.log("queryStr+++", scheme)
            // 主要实现代码
            window.location.href = scheme;

            var startTime = Date.now();
            var count = 0;
            var endTime = 0;

            var t = setInterval(function () {
                count += 1;
                endTime = Date.now() - startTime;
                if (endTime > 800) {
                    clearInterval(t);
                }
                if (count < 30) return;
                if (!(document.hidden || document.webkitHidden)) {
                    Vue.$toast({
                        message: "请您先下载腾讯地图",
                        position: "middle",
                        duration: 1500
                    });
                }
            }, 20);

            window.onblur = function () {
                clearInterval(t);
            };
        } else {
            Vue.$toast({
                message: "获取不到定位，请检查手机定位设置",
                position: "middle",
                duration: 1500
            });
        }
        // }
        // });
    },
    // sortArrFn(arr,key){
    //     console.log(arr)
    //     return arr.sort((a,b)=>{
    //         let x = a[key]
    //         let y = b[key]
    //         return x < y ? -1 : x > y ? 1 : 0
    //     })
    // },
    compare(key) {
        return function (value1, value2) {
            var val1 = value1[key];
            var val2 = value2[key];
            return val1 - val2;
        };
    },
    // throttle(fn,delay){
    //     var lastTime;
    //     var timer;
    //     var delay = delay || 200;
    //     return function() {
    //       var args = arguments;
    //       // 记录当前函数触发的时间
    //       var nowTime = Date.now();
    //       if (lastTime && nowTime - lastTime < delay) {
    //         clearTimeout(timer);
    //         timer = setTimeout(function () {
    //           // 记录上一次函数触发的时间
    //           lastTime = nowTime;
    //           // 修正this指向问题
    //           fn.apply(this, args);
    //         }, delay);
    //       }else{
    //         lastTime = nowTime;
    //         fn.apply(this, args);
    //       }
    //     }
    // },
    debounce(func, wait, immediate) { //防抖
        let timer;
        return function () {
            let context = this,
                args = arguments;

            if (timer) clearTimeout(timer);
            if (immediate) {
                let callNow = !timer;
                timer = setTimeout(() => {
                    timer = null;
                }, wait);
                if (callNow) func.apply(context, args);
            } else {
                timer = setTimeout(() => {
                    func.apply
                }, wait)
            }
        }
    },
    throttle(func, wait) { // 节流，连续触发事件但是在 n 秒中只执行一次函数。
        let previous = 0
        return function () {
          const now = Date.now()
          const context = this
          const args = arguments
          if (now - previous > wait) {
            func.apply(context, args)
            previous = now
          }
        }
    },
    myFilter(arr1, arr2, val) {
        return arr1.filter((ele) =>
            arr2.filter((x) => x !== ele[val]).length > 0
        );
    },
    stringTruncation(value) {
        if (!value) return;
        return (
            value.substr(0, 4) +
            "/" +
            value.substr(4, 2) +
            "/" +
            value.substr(6, 2)
        );
    },
    getRequest() {
        var url = window.location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            var strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = decodeURLcomponent(strs[i].split("=")[1]);
            }
        }
        return theRequest;
    },
    /**
     * 解析URL传参
     * @param {Object} key
     */
    getQueryStringhxf(key) {
        var after = window.location.search;
        if (after.indexOf('?') === -1) return null; //如果url中没有传参直接返回空

        //key存在先通过search取值如果取不到就通过hash来取
        after = after.substr(1) || window.location.hash.split("?")[1];

        if (after) {
            var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
            var r = after.match(reg);
            if (r != null) {
                return decodeURIComponent(r[2]);
            } else {
                return null;
            }
        }
    },
    accSub(arg1, arg2) {
        var r1, r2, m, n;
        try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
        try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
        m = Math.pow(10, Math.max(r1, r2));
        n = (r1 >= r2) ? r1 : r2;
        return ((arg1 * m - arg2 * m) / m).toFixed(n);
    }
}
